package com.example.demofdfs.db.mysql;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public abstract class DBConnect {

	private final static String URL = "jdbc:mysql://127.0.0.1:3306/db_cps?characterEncoding=utf8&useSSL=false";
	private final static String USER = "root";
	private final static String PASSWORD = "root";
	private final static String DRIVER = "com.mysql.cj.jdbc.Driver";
	
	private static Connection MYSQL_CONNECTION;
	
	public static final Connection conncet() {
		if(MYSQL_CONNECTION == null) {
			try {
				Class.forName(DRIVER);
				MYSQL_CONNECTION = DriverManager.getConnection(URL, USER, PASSWORD);
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return MYSQL_CONNECTION;
	}
	
	public static void main(String[] args) {
		System.out.println(conncet());
	}
	
}
